﻿using ITSM.Service;
using Microsoft.AspNetCore.Mvc;

namespace ITSM.Controllers.User
{
    [Route("api/[controller]")]
    [ApiController]
    public class ALLITController: ControllerBase
    {
        private readonly IDemand _demand;
        private readonly IDemandTypeLink  _typeLink;
        private readonly IUserInfo _userInfo;
        public ALLITController(IDemand demand, IDemandTypeLink typeLink, IUserInfo userInfo)
        {
            _demand = demand;
            _typeLink = typeLink;
            _userInfo = userInfo;
        }
        /// <summary>
        /// 根据公司编号获取所有IT人员处理订单数量
        /// </summary>
        /// <param name="RYD_Company"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Get(string RYD_Company)
        {
            if (string.IsNullOrWhiteSpace(RYD_Company))
            {
                return NotFound();
            }
            return Ok(_demand.GetUserState(_typeLink.GetDemandTypeLink(RYD_Company, new string[] {})));
        }
        [HttpGet("/api/GetAllIt")]
        public IActionResult GetAllIt(string RYD_Company,int RYD_TypeId)
        {
            if (string.IsNullOrWhiteSpace(RYD_Company))
            {
                return NotFound();
            }
            
            string[] strArr;
            if (RYD_TypeId!=0)
            {
                strArr = new string[1];
                strArr[0] = RYD_TypeId+"";
            }
            else
            {
                strArr = new string[0];
            }
            return Ok(_userInfo.GetUserInfo(_typeLink.GetDemandTypeLink(RYD_Company, strArr)));
        }

        /// <summary>
        /// 根据公司编号获取所有IT人员姓名和ID
        /// </summary>
        /// <param name="RYD_Company"></param>
        /// <returns></returns>
        [HttpGet("/api/GetAllItName")]
        public IActionResult GetAll(string RYD_Company)
        {
            if (string.IsNullOrWhiteSpace(RYD_Company))
            {
                return NotFound();
            }
            return Ok(_userInfo.GetAllItName(RYD_Company));
        }
    }
}
